<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <pe:head>
        <title>#{bundle.tax}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        
    </pe:head>
    <h:body>
        
    <ui:composition>    
            <h:form>
               <script type="text/javascript">  
                    function handleSaveTax(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgTax.hide();  
                        }  
                    }

                    function handleDeleteTax(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgDeltax.hide();  
                        }  
                    }
                    
                </script>

                <p:toolbar>
                    <p:toolbarGroup align="left">
                         <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document" 
						  rendered="#{menuBean.cekButtonAccess(562,'INS;')}"
                                         action="#{taxBean.newData()}" oncomplete="dlgTax.show();" 
                                         update=":#{utilityBean.findClientId('displayTax')}" process="@this">
                            <pe:resetEditableValues for="displayTax" />  
                        </p:commandButton>   
                  
                        <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgTax.show()"
                                         actionListener="#{taxBean.openData()}" rendered="#{menuBean.cekButtonAccess(562,'OPN;')}"
                                         icon="ui-icon-disk" 
                                         update=":#{utilityBean.findClientId('displayTax')}" /> 

                        <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                         onclick="dlgDeltax.show()" rendered="#{menuBean.cekButtonAccess(562,'DEL;')}" />
                    </p:toolbarGroup>
                </p:toolbar>

                <p:dataTable var="tax" value="#{taxBean.taxs}" id="dtTaxs"
                             selection="#{taxBean.selectedData}" selectionMode="single" rowKey="#{tax.taxId}" resizableColumns="true" >
                    
                    <p:column style="width:100px;" sortBy="#{tax.taxName}">
                        <f:facet name="header">#{bundle.globalName}</f:facet>
                        <h:outputText value="#{tax.taxName}" />
                    </p:column>
                    <p:column style="width:80px;">
                        <f:facet name="header">#{bundle.taxRate}</f:facet>
                        <h:outputText styleClass="numPos" value="#{tax.taxRate} %" >
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                            
                    </p:column>
                    <p:column style="width:300px;">
                        <f:facet name="header">#{bundle.accountName}</f:facet>
                        <h:outputText value="#{taxBean.getGLName(tax.glaccountId)}" />
<!--                        <h:outputText value="#{tax.glaccnt.accountName}" />-->
                    </p:column>
                </p:dataTable>
                
           
                <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                                 header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDeltax">  
                    <p:commandButton value="#{bundle.btnYes}" update="dtTaxs" process="@this"
                                     oncomplete="handleDeleteTax(xhr, status, args)"  
                                     actionListener="#{taxBean.delete()}" />  
                    <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDeltax.hide()" type="button" />   
                </p:confirmDialog> 
          
           
            </h:form>        
            
            <p:dialog header="#{bundle.tax}" widgetVar="dlgTax" closable="true" dynamic="true" modal="true" appendToBody="true">
                    <p:ajax event="close" listener="#{taxBean.handleClose}"/>
                    
                    <h:form>    
                    <h:panelGrid id="displayTax" columns="3" styleClass="addELIT" cellpadding="0" cellspacing="5">
                        <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value= ":" />
                        <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{taxBean.unsaveData!=null}">
                            <p:inputText value="#{taxBean.unsaveData.taxName}" 
                                     required="true" label="#{bundle.globalName}" style="width: 170px"
                                     requiredMessage="#{bundle.globalName} #{bundle.requiredInput}"
                                     id="taxName1" >
                                <p:ajax update="msgtaxName1" process="@this"/>
                            </p:inputText>
                            <p:message id="msgtaxName1" for="taxName1" display="icon" />
                        </h:panelGrid>

                        <h:outputLabel value= "#{bundle.taxRate}" /><h:outputLabel value= ":" />
                        <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{taxBean.unsaveData!=null}">
                            <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="999.99" minValue="0" 
                                styleClass="percent" value="#{taxBean.unsaveData.taxRate}" style="width: 170px"
                                required="true" label="#{bundle.taxRate}" 
                                requiredMessage="#{bundle.taxRate} #{bundle.requiredInput}"
                                     id="taxRate1" >
                                <p:ajax update="msgtaxRate1" process="@this"/>
                            </pe:inputNumber>
                            <p:message id="msgtaxRate1" for="taxRate1" display="icon" />
                        </h:panelGrid>

<!--                        <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.glaccnt}" /><h:outputLabel value= ":" />
                        <p:selectOneMenu value="#{taxBean.unsaveData.glaccountId}" style="width: 170px" rendered="#{taxBean.unsaveData!=null}"
                                         required="true" requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" id="taxGlaccnt1" >
                            
                            <f:selectItems value="#{taxBean.availableGL}" />
                        </p:selectOneMenu>-->
                        
                        <h:outputLabel value= "#{bundle.glaccnt}" /><h:outputLabel value= ":" />
                        <p:selectOneMenu value="#{taxBean.unsaveDataGl}" style="width: 300px" 
                                         rendered="#{taxBean.unsaveData!=null}"
                                         required="true" requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" id="taxGlaccnt1"
                                         label="akun" var="gl" converter="glaccnt" >
                            <f:selectItem rendered="#{taxBean.unsaveDataGl!=null}" itemLabel="#{taxBean.unsaveDataGl.accountName}" itemValue="#{taxBean.unsaveDataGl}" />
                            <f:selectItems value="#{taxBean.availableGL}"   var="glaccnt" itemLabel="#{glaccnt.accountName}" itemValue="#{glaccnt}" />
                            <p:column>#{gl.accountNo}</p:column>
                            <p:column>#{gl.accountName}</p:column>
<!--                         var="gl" itemLabel="#{gl.accountName}" itemValue="#{gl}"    var="gl" converter="glaccnt"-->
                        </p:selectOneMenu>
                    </h:panelGrid>

                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">
                            <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{taxBean.save()}" rendered="#{menuBean.cekButtonAccess(562,'UPD;')}"
                                             update=":#{utilityBean.findClientId('dtTaxs')}" id="submitTax"
                                             oncomplete="handleSaveTax(xhr, status, args)"/>
                            <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgTax.hide()" icon="ui-icon-document" process="@this" >
                                <pe:resetEditableValues for="displayTax"/>
                            </p:commandButton>
                        </f:facet>
                    </h:panelGrid>
                   <p:defaultCommand target="submitTax" /> 
                   
                   </h:form>
                </p:dialog> 
            
        
        </ui:composition>    
    </h:body>
</html>
